<template>
  <div class="execution">
    <basic-container>
      <div class="info-row">

        <div class="info-body">
          <div class="info-header">
            <h4>店铺基本信息</h4>
            <div class="link-top"></div>
          </div>
          <div class="info-main">
            <ul class="info-desc-list">
              <li class="info-desc-item">
                <label>店铺名称:</label>
                <span>{{ rmsAuditDetails.name }}</span>
                <label style="min-width: 10em">所属平台：</label>
                <span>{{ rmsAuditDetails.platformName }}</span>
                <label style="min-width: 10em">店铺头像：</label>
                <img :src="rmsAuditDetails.icon" alt="" class="imgIcon">
              </li>
            </ul>
          </div>
        </div>

        <div class="info-body">
          <div class="info-header">
            <h4>联系人信息</h4>
            <div class="link-top"></div>
          </div>
          <div class="info-main">
            <ul class="info-desc-list">
              <li class="info-desc-item">
                <label>联系人姓名:</label>
                <span>{{ rmsAuditDetails.contactName }}</span>
                <label style="min-width: 10em">联系人电话：</label>
                <span>{{ rmsAuditDetails.contactPhone }}</span>
                <label style="min-width: 10em">联系人邮箱：</label>
                <span>{{ rmsAuditDetails.contactEmail }}</span>
              </li>
              <li class="info-desc-item">
                <label>身份证姓名:</label>
                <span>{{ rmsAuditDetails.cardName }}</span>
                <label style="min-width: 10em">身份证号码：</label>
                <span>{{ rmsAuditDetails.cardId }}</span>
              </li>
              <li class="info-desc-item">
                <label>身份证正面图片:</label>
                <img :src="rmsAuditDetails.cardUrlPositive" alt="" class="imgIcon">
                <label style="min-width: 10em">身份证反面图片：</label>
                <img :src="rmsAuditDetails.cardUrlTos" alt="" class="imgIcon">
              </li>
            </ul>
          </div>
        </div>

        <div class="info-body">
          <div class="info-header">
            <h4>公司信息</h4>
            <div class="link-top"></div>
          </div>
          <div class="info-main">
            <ul class="info-desc-list">
              <li class="info-desc-item">
                <label>企业名称:</label>
                <span>{{ rmsAuditDetails.companyName }}</span>
              </li>
              <li class="info-desc-item">
                <label>企业地址:</label>
                <span>{{ rmsAuditDetails.province }}{{ rmsAuditDetails.addressProvince }}</span>
              </li>
              <li class="info-desc-item">
                <label>统一信用代码:</label>
                <span>{{ rmsAuditDetails.creditId }}</span>
              </li>
              <li class="info-desc-item">
                <label>营业执照图片:</label>
                <img :src="rmsAuditDetails.creditUrl" alt="" class="imgIcon">
              </li>
            </ul>
          </div>
        </div>

        <div class="info-body" v-if="isAudit">
          <div class="info-header">
            <h4>审核信息</h4>
            <div class="link-top"></div>
          </div>
          <div class="info-main">
            <ul class="info-desc-list">
              <li class="info-desc-item">
                <el-input
                  style="width: 85%;padding-left:6%"
                  type="textarea"
                  :autosize="{ minRows: 2, maxRows: 4}"
                  placeholder="请输入内容"
                  v-model="textarea">
                </el-input>
              </li>
            </ul>
          </div>
        </div>
        <div class="info-button" v-if="isAudit">
          <el-button type="info" plain @click="handleNo">不通过</el-button>
          <el-button type="primary" plain @click="handleAdopt">通过</el-button>
        </div>
      </div>
    </basic-container>
  </div>
</template>

<script>
import "@/styles/index.scss";
import { storeDetails,examine } from "@/api/rms/rmsstore";

export default {
  name: 'auditDetails',
  props: {
    isAudit: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      rmsAuditDetails: {},
      textarea: null,
    }
  },
  created() {
    this.getStoreDetail();
  },
  methods: {
    getStoreDetail() {
      let params = {
        storeId: this.$route.query.storeId
      }
      storeDetails(params).then(response=>{
        this.rmsAuditDetails = response.data.data;
      });
    },
    handleNo() {

      if (!this.textarea) {
        this.$message.warning("请填写反驳原因！");
        return;
      }
      let params = {
        storeId: this.$route.query.storeId,
        status: 4,
        message: this.textarea
      }
      examine(params).then(res => {
        if (res.data.code == 200) {
          this.$message({
            message: res.data.msg,
            type: "success",
            duration: 1000,
          });
          this.goback();
        } else {
          this.$message({
            message: res.data.msg,
            type: "warning",
            duration: 1000,
          });
        }
      })
    },

    handleAdopt () {
      let params = {
        storeId: this.$route.query.storeId,
        status: 1,
      }
      examine(params).then(res => {
        if (res.data.code == 200) {
          this.$message({
            message: res.data.msg,
            type: "success",
            duration: 1000,
          });
          this.goback();
        } else {
          this.$message({
            message: res.data.msg,
            type: "warning",
            duration: 1000,
          });
        }
      })
    },
    goback() {
      this.$router.go(-1)
    },
  }
}
</script>

<style>
.info-button {
  display: flex;
  justify-content: center;
}
</style>